<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="productDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='productDetail.heading'/>"/>
</head>

<s:form id="productForm" action="saveProduct" method="post" validate="true" enctype="multipart/form-data" >
    <li style="display: none">
        <s:hidden key="product.id"/>
    </li>
    <s:textfield key="product.name" required="true" maxlength="100" cssClass="text medium"/>
    <li>
        <s:checkbox key="product.enabled" id="product.enabled" cssClass="checkbox" theme="simple"/>
        <s:label for="product.enabled" value="%{getText('product.enabled')}" cssClass="choice desc" theme="simple"/>
    </li>
    
    <s:radio key="product.brand" name="product.brand.id" required="true" list="brandList" listKey="id" listValue="name"/>
    <s:radio key="product.productType" name="product.productType.id" required="true" list="productTypeList" listKey="id" listValue="name"/>
    <s:textfield key="product.version" required="false" maxlength="255" cssClass="text medium" readonly="true"/>

    <s:file key="product.image" name="file" cssClass="text file" required="false" />
    <c:if test="${not empty product.image}">
        <img src="${product.image}"/>
    </c:if>

    <s:textfield key="product.website" required="false" maxlength="100" cssClass="text medium"/>
    <s:textfield key="product.phone" required="false" maxlength="50" cssClass="text medium"/>
    <s:textfield key="product.numberOfCustomer" required="false" maxlength="50" cssClass="text medium"/>
    <br/>

    <li>
        <s:radio key="product.structure" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.structure.type0'),
                                                 '1':getText('product.structure.type1'),
                                                 '2':getText('product.structure.type2'),
                                                 '3':getText('product.structure.type3')}"/>
    </li>
    <li>
        <s:radio key="product.marketPositioning" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.marketPositioning.type0'),
                                                 '1':getText('product.marketPositioning.type1'),
                                                 '2':getText('product.marketPositioning.type2'),
                                                 '3':getText('product.marketPositioning.type3')}"/>
    </li>
    <li>
        <s:radio key="product.implCycle" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.implCycle.type0'),
                                                 '1':getText('product.implCycle.type1'),
                                                 '2':getText('product.implCycle.type2'),
                                                 '3':getText('product.implCycle.type3'),
                                                 '4':getText('product.implCycle.type4')}"/>
    </li>
    <li>
        <s:radio key="product.totalBudget" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.totalBudget.type0'),
                                                 '1':getText('product.totalBudget.type1'),
                                                 '2':getText('product.totalBudget.type2'),
                                                 '3':getText('product.totalBudget.type3'),
                                                 '4':getText('product.totalBudget.type4'),
                                                 '5':getText('product.totalBudget.type5'),
                                                 '6':getText('product.totalBudget.type6'),
                                                 '7':getText('product.totalBudget.type7')}"/>
    </li>
    <li>
        <s:radio key="product.priceAdvantage" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.priceAdvantage.type0'),
                                                 '1':getText('product.priceAdvantage.type1'),
                                                 '2':getText('product.priceAdvantage.type2'),
                                                 '3':getText('product.priceAdvantage.type3')}"/>
    </li>
    <li>
        <s:radio key="product.numberOfUsers" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.numberOfUsers.type0'),
                                                 '1':getText('product.numberOfUsers.type1'),
                                                 '2':getText('product.numberOfUsers.type2'),
                                                 '3':getText('product.numberOfUsers.type3'),
                                                 '4':getText('product.numberOfUsers.type4'),
                                                 '5':getText('product.numberOfUsers.type5')}"/>
    </li>
    <li>
        <s:radio key="product.rate" theme="xhtml" required="true"
                                                 list="#{
                                                 '0':getText('product.rate.type0'),
                                                 '1':getText('product.rate.type1'),
                                                 '2':getText('product.rate.type2'),
                                                 '3':getText('product.rate.type3'),
                                                 '4':getText('product.rate.type4'),
                                                 '5':getText('product.rate.type5')}"/>
    </li>
    <br/>
    <br/>

    <fieldset>
        <table id="productIndustries" border="0">
            <thead>
                <tr>
                    <th/>
                    <th><fmt:message key="product.industryName"/></th>
                    <th><fmt:message key="product.industryScore"/></th>
                </tr>
            </thead>
            <tbody>
                <s:iterator value="product.productIndustries" status="rowstatus">
                    <tr>
                        <td>
                            <s:hidden name="product.productIndustries[%{#rowstatus.index}].id" value="%{id}" />
                            <s:hidden name="product.productIndustries[%{#rowstatus.index}].product.id" value="%{product.id}" />
                            <s:hidden name="product.productIndustries[%{#rowstatus.index}].industry.id" value="%{industry.id}" />
                            <s:checkbox name="product.productIndustries[%{#rowstatus.index}].enabled" value="%{enabled}" />
                        </td>
                        <td><s:label value="%{industry.name}"/></td>
                        <td><s:radio name="product.productIndustries[%{#rowstatus.index}].score" theme="xhtml" required="true"
                                         list="#{
                                         '0':getText('product.industryScore.type0'),
                                         '1':getText('product.industryScore.type1'),
                                         '2':getText('product.industryScore.type2'),
                                         '3':getText('product.industryScore.type3'),
                                         '4':getText('product.industryScore.type4'),
                                         '5':getText('product.industryScore.type5')}"/>
                        </td>
                    </tr>
                </s:iterator>
            </tbody>
        </table>
    </fieldset>
    <br/>

    <fieldset>
        <table id="productModules">
            <thead>
                <tr>
                    <th/>
                    <th><fmt:message key="product.moduleName"/></th>
                    <th><fmt:message key="product.moduleScore"/></th>
                </tr>
            </thead>
            <tbody>
                <s:iterator value="product.productModules" status="rowstatus">
                    <tr>
                        <td>
                            <s:hidden name="product.productModules[%{#rowstatus.index}].id" value="%{id}" />
                            <s:hidden name="product.productModules[%{#rowstatus.index}].product.id" value="%{product.id}" />
                            <s:hidden name="product.productModules[%{#rowstatus.index}].module.id" value="%{module.id}" />
                            <s:checkbox name="product.productModules[%{#rowstatus.index}].enabled" value="%{enabled}" />
                        </td>
                        <td><s:label value="%{module.name}"/></td>
                        <td><s:radio name="product.productModules[%{#rowstatus.index}].score" theme="xhtml" required="true"
                                         list="#{
                                         '0':getText('product.moduleScore.type0'),
                                         '1':getText('product.moduleScore.type1'),
                                         '2':getText('product.moduleScore.type2'),
                                         '3':getText('product.moduleScore.type3'),
                                         '4':getText('product.moduleScore.type4'),
                                         '5':getText('product.moduleScore.type5')}"/>
                        </td>
                    </tr>
                </s:iterator>
            </tbody>
        </table>
    </fieldset>

    <s:textfield key="product.position" required="true" maxlength="255" cssClass="text medium"/>
    <s:textarea key="product.comments" required="false" maxlength="254" cssClass="textarea medium"/>
    <s:textarea key="product.description" required="false" maxlength="254" cssClass="textarea medium"/>


    <li class="buttonBar bottom">
        <s:submit cssClass="button" method="save" key="button.save" theme="simple"/>
        <c:if test="${not empty product.id}">
            <s:submit cssClass="button" method="delete" key="button.delete"
                onclick="return confirmDelete('Product')" theme="simple"/>
        </c:if>
        <s:submit cssClass="button" method="cancel" key="button.cancel" theme="simple"/>
    </li>
</s:form>

<script type="text/javascript">
    Form.focusFirstElement($("productForm"));
</script>
